package 时间;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class 时间 {
    public static void main(String[] args) throws ParseException {
        Date d1 = new Date(10000L);
        d1.setTime(10000000000L);
        System.out.println(d1.getTime());
//        System.out.println(d1);

//        Random r = new Random();
//        for (int i = 0 ; i <5 ; i++) {
//            System.out.println(Math.abs(r.nextInt())/1000/60/60/24);
//        }

        //格式化
         Date d2 = new Date(0L);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH时:mm分:ss秒 E");
        String f1 = sdf.format(d2);
        System.out.println(f1);

        //解析parse
        String s1 = "2025-2-24 22:23:01";
        SimpleDateFormat sdf01 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d3 = sdf01.parse(s1);
        System.out.println(d3);

        //calendar日历对象,Calendar是抽象类
        Calendar cld = Calendar.getInstance();
        System.out.println(cld.get(Calendar.YEAR));
        System.out.println(cld.getTime());//返回Date对象

        Date d4 = new Date(0L);
        Calendar cld01 = Calendar.getInstance();
        //cld01.setTime(d4);
        System.out.println(cld01.get(Calendar.DAY_OF_WEEK_IN_MONTH));



    }
}
